package com.kingdee.eas.minghua.trademanage.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;

import com.kingdee.eas.minghua.jczlwh.mj.SfshEnum;
import com.kingdee.eas.minghua.trademanage.OrderCollection;
import com.kingdee.eas.minghua.trademanage.OrderFactory;
import com.kingdee.eas.minghua.trademanage.POorderFactory;
import com.kingdee.eas.minghua.trademanage.POorderInfo;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.minghua.trademanage.OrderInfo;
import com.kingdee.eas.util.app.ContextUtil;
import com.kingdee.eas.xinrui.publicbill.AuditStateEnum;
import com.kingdee.eas.framework.SystemEnum;
import com.kingdee.eas.framework.CoreBillBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.app.CoreBillBaseControllerBean;
import com.kingdee.eas.framework.ObjectBaseCollection;

public class OrderControllerBean extends AbstractOrderControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.minghua.trademanage.app.OrderControllerBean");
    
	protected boolean _Audit(Context ctx, String Audit) throws BOSException {
		OrderInfo poinfo;
		try {
			poinfo = OrderFactory.getLocalInstance(ctx).getOrderInfo(new ObjectUuidPK(Audit));
			if (!poinfo.getDjStage().equals(SfshEnum.yes)) {
				poinfo.setAuditor(SysContext.getSysContext().getCurrentUserInfo());
				poinfo.setDjStage(SfshEnum.yes);
				SelectorItemCollection sel = new SelectorItemCollection();
				sel.add("djStage");
				OrderFactory.getLocalInstance(ctx).updatePartial(poinfo, sel);
			}
		} catch (EASBizException e) {
			e.printStackTrace();
		}
		return super._Audit(ctx, Audit);
	}

	protected boolean _UnAudit(Context ctx, String UnAudit) throws BOSException {
		OrderInfo poinfo;
		try {
			poinfo = OrderFactory.getLocalInstance(ctx).getOrderInfo(new ObjectUuidPK(UnAudit));
			if (!poinfo.getDjStage().equals(SfshEnum.save)) {
				poinfo.setAuditor(SysContext.getSysContext().getCurrentUserInfo());
				poinfo.setDjStage(SfshEnum.save);
				SelectorItemCollection sel = new SelectorItemCollection();
				sel.add("djStage");
				OrderFactory.getLocalInstance(ctx).updatePartial(poinfo, sel);
			}
		} catch (EASBizException e) {
			e.printStackTrace();
		}
		return super._UnAudit(ctx, UnAudit);
	}
}